{% extends 'base_backend.html' %}
{% load static %}
{% load my_filter %}
{% block header_tail %}
<link rel="stylesheet" href="{% static 'public/CodeMirror/lib/codemirror.css' %}">
<link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
<link rel="stylesheet" href="{% static 'public/CodeMirror/theme/lesser-dark.css' %}">
<link rel="stylesheet" href="{% static 'public/CodeMirror/addon/dialog/dialog.css' %}">
<link rel="stylesheet" href="{% static 'public/CodeMirror/addon/search/matchesonscrollbar.css' %}">
<link rel="stylesheet" href="{% static 'plugins/select2/select2.css' %}">
<link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
<link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">
<script src="{% static 'plugins\jQuery\jquery-2.2.3.min.js' %}"></script>
<script src="{% static 'plugins/vue1/vue.js' %}"></script>

<style>
    .login-banner {
        width: 100%;
        background: url("{% static 'public/img/banner2.jpg' %}") center bottom/cover no-repeat;
    }
</style>
{% endblock header_tail %}

{% block section_content %}
<div>
    <div class="box-header with-border">
        <h3 class="box-title">{{ model_verbose_name }}</h3>
    </div>
    <!-- form start -->
    <div class="box box-primary">
        <div class="box-body">
            <input class="no-display" type="text">
            <p style="clear: both"></p>
            <div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">任务ID：</label>
                    <p id="taskId" type="text" class="config-input">{{ task.id }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">项目ID：</label>
                    <p type="text" class="config-input">{{ task.project_id }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">网站名称：</label>
                    <p type="text" class="config-input">{{ task.site_name }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">网站URL：</label>
                    <p type="text" class="config-input">{{ task.site_url }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">域名：</label>
                    <p type="text" class="config-input">{{ task.domain }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">一级域名：</label>
                    <p type="text" class="config-input">{{ task.first_domain }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">分配时间：</label>
                    <p type="text" id="allocation_flag" class="config-input"></p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">通过时间：</label>
                    <p id="finish_flag" type="text" class="config-input"></p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">任务备注：</label>
                    <p type="text" class="config-input">{{ task.note }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">录入时间：</label>
                    <p type="text" id="ctime" class="config-input"></p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">用户ID：</label>
                    <p type="text" class="config-input">{{ task.uid }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">网站国家：</label>
                    <p type="text" class="config-input">
                        {% if task.country %}
                        {{ task.country }}
                        {% else %}

                        {% endif %}
                    </p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">网站语言：</label>
                    <p type="text" class="config-input">{{ task.lang }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">任务描述：</label>
                    <p type="text" class="config-input">{{ task.description }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">任务状态：</label>
                    <p type="text" class="config-input">{{ task.description }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <label for="id" class="control-label">ICP：</label>
                    <p type="text" class="config-input">{{ task.icp }}</p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <p><a href="{% url 'fieldverify:config_change' task.id %}" class="btn btn-success">详情</a></p>
                    <p><a href="{% url 'fieldverify:debug_config' task.id %}" class="btn btn-success" target="_blank">测试</a></p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <p><a href="{% url 'fieldverify:change_history' task.config_id %}" class="btn btn-success" target="_blank">代码历史</a></p>
                    <p><a href="{% url 'fieldverify:data_size' task.id %}" class="btn btn-success" target="_blank">数据量统计</a></p>
                </div>
                {% if user.is_superuser %}
                <div style="float: left;" class="input-group select-config-div">
                    <p><a href="http://ispider.istarshine.com/config/{{ task.config_id }}/change/" class="btn btn-success" target="_blank">采集后台</a></p>
                    <p><a href="{% url 'fieldverify:operating_record' 'task' %}?id={{ task.id }}" class="btn btn-success" target="_blank">任务操作记录</a></p>
                </div>
                <div style="float: left;" class="input-group select-config-div">
                    <p><a href="{% url 'fieldverify:result_contrast' task.id %}" class="btn btn-success" target="_blank">结果对比</a></p>
                </div>
                {% endif %}
            </div>
            <!--  审核记录 start  -->
            <div class="row">
                <div class="col-md-12">
                    <!-- DIRECT CHAT -->
                    <div class="box box-primary direct-chat direct-chat-primary collapsed-box">
                        <div class="box-header with-border">
                            <h3 class="box-title">审核记录</h3>
                            <div class="box-tools pull-right">
                                <span data-toggle="tooltip" title="{{ communicatesNum }} Messages"
                                      class="badge bg-blue">{{ review_log_count }}</span>
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                        class="fa fa-plus"></i>
                                </button>
                            </div>
                        </div>
                        <div class="box-body">
                            <table id="auditRecordTable" border="1"
                                   class="table table-bordered table-hover table-striped">
                                <thead>
                                <tr>
                                    <th class="action-checkbox">
                                        <span style="float: left">
                                            审核时间
                                        </span>
                                    </th>
                                    <th style="width: 350px;">
                                        <span style="float: left">
                                            不合格原因
                                        </span>
                                    </th>
                                    <th style="width: 350px;">
                                        <span style="float: left">
                                            配置人员
                                        </span>
                                    </th>
                                    <th>
                                        <span style="float: left">
                                            审核人员
                                        </span>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for review_log in review_log_list %}
                                <tr>
                                    <td>
                                        <span>{{ review_log.ctime|timestamp_format:'%Y-%m-%d %H:%M:%S' }}</span>
                                    </td>
                                    <td>
                                        <span>{{ review_log.content }}</span>
                                    </td>
                                    <td>
                                        <span>{{ review_log.author }}</span>
                                    </td>
                                    <td>
                                        <span>{{ review_log.auditor }}</span>
                                    </td>
                                </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>

                        <div class="box-footer">
                            <div class="input-group">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--  审核记录 end  -->
            <div class="form-group">
                <div style="float: left; color: red;">
                    <label for="" class="control-label">选中列表页：</label>
                    <input type="checkbox" name="th_checkbox_list_all" class="th_checkbox_list_all"
                           value="[[ message.check_result ]]"
                           onclick="checkMany(this, 'td_checkbox_list')">
                    <span id="message" style="margin-left: 20px"></span>
                    <label for="" class="control-label">选中详情页：</label>
                    <input type="checkbox" name="th_checkbox_detail_all" class="th_checkbox_detail_all"
                           value="[[ message.check_result ]]"
                           onclick="checkMany(this, 'td_checkbox_detail')">
                    {% if manage_type == 'task_detail_staff' %}
                        {% if task.status_id == 3 or task.status_id == 6 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="feedback_result()">
                            反馈结果(第一步)
                        </button>
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('apply_recycle', '{{ task.id }}')">
                            申请回收(第一步)
                        </button>
                        {% endif %}
                        {% if task.status_id == 3 or task.status_id == 6 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="feedback_task_submit('{{ task.id }}', 0)">
                            反馈提交(第二步)
                        </button>
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="feedback_task_submit('{{ task.id }}', 1)">
                            修改提交(第二步)
                        </button>
                        {% endif %}
                    {% elif manage_type == 'task_detail_agent' %}
                        {% if task.status_id == 4 or task.status_id == 6 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('qualified', '{{ task.id }}')">
                            合格
                        </button>
                        {% endif %}
                        {% if task.status_id == 4 or task.status_id == 5 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('disqualified', '{{ task.id }}')">
                            不合格
                        </button>
                        {% endif %}
                    {% elif manage_type == 'task_detail_admin' %}
                        {% if task.status_id == 4 or task.status_id == 5 or task.status_id == 6 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('pass', '{{ task.id }}')">
                            通过
                        </button>
                        {% endif %}
                        {% if task.status_id == 4 or task.status_id == 5 or task.status_id == 14 %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('disqualified', '{{ task.id }}')">
                            不合格
                        </button>
                        {% endif %}
                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('recycle', '{{ task.id }}')">
                            回收
                        </button>
                    {% endif %}
                </div>
                <span style="color: #00a7d0;margin-left: 10px"></span>
            </div>

            <!--模板变更信息展示--start-->
            <div class="form-group" id="messageList">
                <table id="message_each_table" border="1" class="table table-bordered table-hover table-striped">
                    <thead>
                    <tr>
                        <th class="action-checkbox">
                            <input type="checkbox" name="th_checkbox_all" onclick="checkAll(this)">
                        </th>
                        <th v-for="head in headers">
                            <span style="float: left">
                                [[ head.name ]]
                            </span>
                        </th>
<!--                        <th v-for="head in ">-->
<!--                            <span style="float: left">-->
<!--                                操作-->
<!--                            </span>-->
<!--                        </th>-->
                    </tr>
                    </thead>
                    <tbody>
                    <template v-for="message in message_list">
                        <tr>
                            <td class="action-checkbox">
                                <input v-if="message.check_result.indexOf('列表页') != -1" type="checkbox"
                                       name="td_checkbox_list" class="td_checkbox" value="[[ message.id ]]"
                                       onclick="checkOne(this)">
                                <input v-else type="checkbox" name="td_checkbox_detail" class="td_checkbox"
                                       value="[[ message.id ]]" onclick="checkOne(this)">
                            </td>
                            <template v-for="head in headers">
                                <td v-if="head.key == 'detail_url' || head.key == 'url'">
                                    <a href="[[ message[head.key] ]]" target="_blank" title="[[ message[head.key] ]]">[[ truncatechars(message[head.key], 80) ]]</a>
                                </td>

<!--                                <div v-else>-->
<!--                                    <td v-if="head.key == 'detail_id' || head.key == 'id'">-->
<!--                                        <a href="{% url 'fieldverify:config_change' task.id %}" target="_blank" title="[[ message[head.key] ]]">[[ truncatechars(message[head.key], 80) ]]</a>-->
<!--                                    </td>-->
                                <td v-else>
                                    <span v-if="head.key == 'detail_id' || head.key == 'id'">
                                        <a href="{% url 'fieldverify:config_change' task.id %}" target="_blank" title="[[ message[head.key] ]]">[[ truncatechars(message[head.key], 80) ]]</a>
                                    </span>
                                    <span v-else>
                                        [[ message[head.key] ]]
                                    </span>
                                </td>
<!--                                </div>-->


                            </template>
                        </tr>
                    </template>
                    </tbody>
                </table>
<!--                <div>-->
<!--                    {% if task.status_id == 3 or task.status_id == 6 %}-->
<!--                    <a v-if="message_list.length == 0" class="btn btn-primary" data-toggle="modal"-->
<!--                       data-target="#submitAudit">完成任务</a>-->
<!--                    {% endif %}-->
<!--                </div>-->
            </div>
            <!--模板变更信息展示--end-->

            <br>
        </div>
    </div>
</div>

<!--弹出任务提交审核提示消息-->
<div class="modal fade" id="submitAudit" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" style="top:40%">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
                <h4 class="modal-title" id="myModalLabel">
					确定要提交审核吗?
				</h4>
            </div>
            <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                如修改过代码请点击<b>修改提交</b>，否则点击<b>反馈提交</b>
            </div>
            <div class="modal-footer" style="text-align:center;">
                <button type="button" class="btn btn-default" onclick="submit_audit('{{ task.id }}', 1)"
                        data-dismiss="modal">修改提交
                </button>
                <button type="button" class="btn btn-default" onclick="submit_audit('{{ task.id }}', 0)"
                        data-dismiss="modal">反馈提交
                </button>
            </div>
        </div>
    </div>
</div>

<!--反馈结果--start-->
<div class="modal fade" id="feedbackList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top:5%">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body" style="overflow:auto">
                <label>反馈结果：</label>
                <table id="feedback_each_table" border="1" class="table table-bordered table-hover table-striped">
                    <thead>
                    <tr>
                        <th class="action-checkbox">
                        </th>
                        <th>
                            <span style="float: left">
                                反馈结果
                            </span>
                        </th>
                    </tr>
                    </thead>
<!--                    <tbody>-->
                    <tr>
                        <td class="action-checkbox">
                            <input id="ctime_gtime" type="radio" name="feedback_radio"
                                   value="1">
                        </td>
                        <td>
                            <label for="ctime_gtime" class="control-label">ctime与gtime相同</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="title_content" type="radio" name="feedback_radio"
                                   value="2">
                        </td>
                        <td>
                            <label for="title_content" class="control-label">title与content相同</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="sit_name" type="radio" name="feedback_radio"
                                   value="3">
                        </td>
                        <td>
                            <label for="sit_name" class="control-label">siteName</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="white_list" type="radio" name="feedback_radio"
                                   value="4">
                        </td>
                        <td>
                            <label for="white_list" class="control-label">白名单</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="jude_mistake" type="radio" name="feedback_radio"
                                   value="5">
                        </td>
                        <td>
                            <label for="jude_mistake" class="control-label">误判</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="link_mistake" type="radio" name="feedback_radio"
                                   value="8">
                        </td>
                        <td>
                            <label for="link_mistake" class="control-label">链接有误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="more_mistake" type="radio" name="feedback_radio"
                                   value="9">
                        </td>
                        <td>
                            <label for="more_mistake" class="control-label">多种错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="no_title_content" type="radio" name="feedback_radio"
                                   value="182">
                        </td>
                        <td>
                            <label for="no_title_content" class="control-label">不监控title_content</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="title_mistake" type="radio" name="feedback_radio"
                                   value="186">
                        </td>
                        <td>
                            <label for="title_mistake" class="control-label">标题错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="text_filter" type="radio" name="feedback_radio"
                                   value="185">
                        </td>
                        <td>
                            <label for="text_filter" class="control-label">正文过滤</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="no_ctime" type="radio" name="feedback_radio"
                                   value="190">
                        </td>
                        <td>
                            <label for="no_ctime" class="control-label">不监控ctime=gtime</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="no_title" type="radio" name="feedback_radio"
                                   value="192">
                        </td>
                        <td>
                            <label for="no_title" class="control-label">不监控title</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="web_name_mistake" type="radio" name="feedback_radio"
                                   value="199">
                        </td>
                        <td>
                            <label for="web_name_mistake" class="control-label">网站名称错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="group_mistake" type="radio" name="feedback_radio"
                                   value="201">
                        </td>
                        <td>
                            <label for="group_mistake" class="control-label">分组错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="domain_mistake" type="radio" name="feedback_radio"
                                   value="200">
                        </td>
                        <td>
                            <label for="domain_mistake" class="control-label">域名错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">
                            <input id="url_mistake" type="radio" name="feedback_radio"
                                   value="202">
                        </td>
                        <td>
                            <label for="url_mistake" class="control-label">详情url错误</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="action-checkbox">备注</td>
                        <td><textarea class="form-control" id="feedback_remake"></textarea>
                        </td>
                    </tr>
<!--                    </tbody>-->
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="_feedback_result()">确认
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
            </div>
        </div>
    </div>
</div>
<!--反馈结果--end-->

<!--提示消息--start-->
<div class="modal fade" id="disposalMessage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top:40%">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div id="disposalMsgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                <h4 id="promptMessage">提示消息</h4>
                <input style="width:400px;height:100px;display:none" type="text" id="feedbackMessage" placeholder="">
            </div>
            <div class="modal-footer" style="text-align:center;">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="confirm_button">确认
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--提示消息--end-->


<script>

    $("#myTasks").addClass("active");
    Vue.config.delimiters = ["[[", "]]"];

    var messageListVue = new Vue({
        el: "#messageList",
        data: {
            headers: [],
            message_list: [],
            message: ""
        },
        methods: {
            parseTime: function (timeStamp) {
                if (!timeStamp) {
                    return ""
                }
                var newDate = new Date();
                newDate.setTime(timeStamp * 1000);
                return newDate.toLocaleDateString()
            },
            truncatechars :function (str, end){
                if (!str){
                    return ""
                }
                if(end <= str.length){
                    return str.slice(0,end) + '...'
                }else{
                    return str
                }
            }
        }
    });

    function getMessages() {
        var task_detail_api = "{{ task_detail_api }}";
        $.ajax({
            url: task_detail_api,
            type: 'POST',
            data: {
                csrfmiddlewaretoken: "{{ csrf_token }}",
                task_id: "{{ task_id }}"
            },
            success: function (response) {
                messageListVue.headers = response.headers;
                messageListVue.message_list = response.message_list;
            }
        });
    }

    getMessages(messageListVue);

    // 选中全部
    function checkAll(obj) {
        if ($(obj).is(":checked")) {
            $("input[name='td_checkbox_list']").prop("checked", true);
            $("input[name='td_checkbox_detail']").prop("checked", true);
            $("input[class='th_checkbox_list_all']").prop("checked", true);
            $("input[class='th_checkbox_detail_all']").prop("checked", true);
        } else {
            $("input[name='td_checkbox_list']").prop("checked", false);
            $("input[name='td_checkbox_detail']").prop("checked", false);
            $("input[class='th_checkbox_list_all']").prop("checked", false);
            $("input[class='th_checkbox_detail_all']").prop("checked", false);
        }
    }

    // 选中多个
    function checkMany(obj, check_name) {
        if ($(obj).is(":checked")) {
            $("input[name=" + check_name + "]").prop("checked", true);
        } else {
            $("input[name=" + check_name + "]").prop("checked", false);
        }
        checkOne();
    }


    // 选中一个
    function checkOne(obj) {
        if ($("input[name='th_checkbox_all']").is(":checked")) {
            $("input[name='th_checkbox_all']").prop("checked", false)
        } else {
            var unChecked = true;
            $("input[class='td_checkbox']").each(
                function () {
                    if (!$(this).is(":checked")) {
                        unChecked = false;
                    }
                }
            );
            if (unChecked) {
                $("input[name='th_checkbox_all']").prop("checked", true)
            }
        }
    }

    // 反馈结果
    function feedback_result() {
        feedback_list = [];
        $("input[class='td_checkbox']:checked").each(
            function () {
                feedback_list.push($(this).val());
            }
        );

        // 判断是否选中链接
        if (feedback_list.length === 0) {
            alert('没有选中链接');
            return false;
        }
        $("#feedbackList").modal();
    }

    // 提交反馈任务
    function feedback_task_submit(task_id, is_modify) {
        feedback_list = [];
        $("input[class='td_checkbox']:checked").each(
            function () {
                feedback_list.push($(this).val());
            }
        );

        // 判断是否选中链接
        // if (feedback_list.length === 0) {
        //     alert('没有选中链接');
        //     return false;
        // }
        $.ajax({
            url: "{% url 'fieldverify:submit_feedback_audit' %}",
            type: "POST",
            data: {
                csrfmiddlewaretoken: "{{ csrf_token }}",
                task_id: task_id,
                is_modify: is_modify
            },
            success: function (resp) {
                alert(resp.message);
                location.reload();
            }
        })

    }

    function _feedback_result() {
        var flag = $("input[name='feedback_radio']:checked").val();
        var remake = $("#feedback_remake").val();
        var task_id = "{{ task_id }}";
        $.ajax({
            url: "{% url 'fieldverify:feedback_api' %}",
            type: "POST",
            dataType: "json",
            data: {
                csrfmiddlewaretoken: "{{ csrf_token }}",
                task_id: task_id,
                flag: flag,
                remake: remake,
                feedback_list: JSON.stringify(feedback_list),
            },
            success: function (resp) {
                alert(resp.message);
                location.reload();
            }
        })
    }

    // 提交审核
    function submit_audit(task_id, is_modify) {
        $.ajax({
            url: "{% url 'fieldverify:submit_audit' %}",
            type: "POST",
            data: {
                csrfmiddlewaretoken: "{{ csrf_token }}",
                task_id: task_id,
                is_modify: is_modify
            },
            success: function (resp) {
                alert(resp.message);
                location.reload();
            }
        })
    }

    function BubbleTooltip(type, task_id) {
        switch (type) {
            case 'qualified':
                var change_status_api = "{% url 'fieldverify:qualified' %}";
                $('#promptMessage').html("确定修改为合格吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                break;
            case 'disqualified':
                var change_status_api = "{% url 'fieldverify:disqualified' %}";
                $('#promptMessage').html("确定修改为不合格吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                $('#feedbackMessage').css("display", "block");
                break;
            case 'pass':
                var change_status_api = "{% url 'fieldverify:passed' %}";
                $('#promptMessage').html("确定通过吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                break;
            case 'recycle':
                var change_status_api = "{% url 'fieldverify:recycle' %}";
                $('#promptMessage').html("确定回收吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                $('#feedbackMessage').css("display", "block");
                break;
            case 'apply_recycle':
                var change_status_api = "{% url 'fieldverify:apply_recycle' %}";
                $('#promptMessage').html("确定申请回收吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                $('#feedbackMessage').css("display", "block");
                break;
            case 'feedback_info':
                var change_status_api = "{% url 'fieldverify:feedback_info' %}";
                $('#promptMessage').html("确定回收吗？");
                $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                $('#feedbackMessage').css("display", "block");
                break;
        }
        $('#disposalMessage').modal();
    }

    // 修改状态
    function changeStatus(task_id, change_status_api) {
        var feedbackMessage = $("#feedbackMessage").val();
        $.ajax({
            url: change_status_api,
            type: "POST",
            data: {
                csrfmiddlewaretoken: "{{ csrf_token }}",
                task_id: task_id,
                feedbackMessage: feedbackMessage
            },
            success: function (resp) {
                alert(resp.message);
                location.reload();
            }
        })
    }
</script>
{% endblock section_content %}